#coding=utf-8

from fetchContent import FetchContent
import threading

lock = threading.RLock()

class DMBJ(threading.Thread):
    
    def __init__(self,threadName):
        threading.Thread.__init__(self,name=threadName)
        
    def run(self):
        lock.acquire()
        f = open("c:\\url.txt",'rb')
        list_line = f.readlines()
        f.close()
        lock.release()
        for line in list_line:
            print "ok=%s"%self.getName()
            lineArray = line.split("$")
            fetchText = FetchContent(lineArray[1], unicode(lineArray[0],'utf8','ignore').encode('gb2312','ignore'))
            fetchText.fetch()
            list_line.remove(line)
        print "finish"
        

if __name__ == '__main__':
    for i in range(10):
        d = DMBJ("dmbj"+str(i))
        d.start()